<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>函数检测参数是否合适</title>
        <script lanuage="JavaScript">
            function detect_age(){
                var value = document.getElementById("age").value;
                value = parseInt(value);
                // alert(value);
                if(value<0||value>200||window.isNaN(value)){
                    // alert("warring");
                    document.getElementById("age_hint").innerHTML="年龄（0-200之间）";
                }
                else{
                    document.getElementById("age_hint").innerHTML="";
                }
            }
            function detect_account(){
                var value=document.getElementById("account").value;
                value = String(value);
                // alert(value);
                if(value==''){
                    document.getElementById("account_hint").innerHTML="账号不能为空";
                }
                else{
                    document.getElementById("account_hint").innerHTML="";
                }
            }
        </script>
    </head>
    <body>
        <form>
            <table>
                <tr>
                    <td><span>年龄：</span></td>
                    <td><input type="text" id="age" onblur="detect_age()"></td>
                    <td><span id="age_hint" style="color:red"></span></td>
                </tr>
                <tr>
                    <td><span>参数：</span></td>
                    <td><input type="text" id="account" onblur="detect_account()"></td>
                    <td><span id="account_hint" style="color:red"></span></td>
                </tr>
            </table>
        </form>

    </body>
</html>